# Maintainer:  Jan de Groot <jan@archlinux.org>

pkgname=gconf
pkgver=3.2.6+11+g07808097
pkgrel=3
pkgdesc="A configuration database system"
url="https://projects-old.gnome.org/gconf/"
arch=(x86_64)
license=(LGPL)
depends=(libxml2 polkit libldap dbus-glib)
makedepends=(intltool gtk-doc gobject-introspection git gnome-common)
install=gconf.install
_commit=0780809731c8ab1c364202b1900d3df106b28626  # master
source=("git+https://git.gnome.org/browse/gconf#commit=$_commit"
        01_xml-gettext-domain.patch gconf-reload.patch
        gconf-merge-schema gconfpkg gconf-{install,remove}.hook)
sha256sums=('SKIP'
            'c883dec2b96978874a53700cfe7f26f24f8296767203e970bc6402b4b9945eb8'
            '567b78d8b4b4bbcb77c5f134d57bc503c34867fcc6341c0b01716bcaa4a21694'
            'ee6b6e6f4975dad13a8c45f1c1f0547a99373bdecdcd6604bfc12965c328a028'
            'bf1928718caa5df2b9e54a13cfd0f15a8fe0e09e86b84385ce023616a114e898'
            '2732b2a6b187c5620105a036bde12edee99669605f70cbde56fe5f39619c3dc0'
            '436a65ff290095bc3d35d7d6297cf4d647f61e9f9922cea7ef9f1e251b447ff7')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd $pkgname

  # Patch from fedora - reloads gconf after installing schemas
  patch -Np1 -i ../gconf-reload.patch

  # http://bugzilla.gnome.org/show_bug.cgi?id=568845
  patch -Np1 -i ../01_xml-gettext-domain.patch

  # Python2 fix
  sed -i '1s|#!/usr/bin/env python$|&2|' gsettings/gsettings-schema-convert

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgname
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir=/usr/lib \
    --enable-defaults-service \
    --disable-gtk-doc \
    --disable-static \
    --disable-orbit
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd $pkgname
  make check
}

package() {
  DESTDIR="$pkgdir" make -C $pkgname install

  install -d "$pkgdir/etc/gconf/gconf.xml.system"
  install -Dt "$pkgdir/usr/bin" gconf-merge-schema gconfpkg
  install -Dt "$pkgdir/usr/share/libalpm/hooks" -m644 *.hook
}
